﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Secams.model;
using Secams.controller;
using Secams.utils;

namespace Secams.form
{
    public partial class FormDecision : Form
    {
        bool _isCancelable = false;
        NiEvent lastEvent = null;

        public FormDecision(bool isCancelable, NiEvent lastEvent)
        {
            _isCancelable = isCancelable;
            this.Font = AppContext.getDefaultFont(this.Font);
            InitializeComponent();
            if (!_isCancelable)
                this.btnCancel.Visible = false;

            this.lastEvent = lastEvent;
        }

        private void FormDecision_Load(object sender, EventArgs e)
        {
            //txtTrialStatus.Text = "[" + this.lastEvent.id + "]" + this.lastEvent.signature + " | " + this.lastEvent.description;
        }

        public string getDecision()
        {
            return this.cboDecision.Text;
        }

        public string getReason()
        {
            return this.txtDecisionReason.Text;
        }

        public int getConfidence()
        {
            return cboDecisionConfidene.SelectedIndex;
        }

        bool validateFields()
        {
            bool retval = true;
            if (!ControlUtils.checkComboBox(ref this.cboDecisionConfidene, ref lblDecisionConfidene))
                retval = false;
            if (!ControlUtils.checkTextBox(ref this.txtDecisionReason, ref lblDecisionReason))
                retval = false;
            if (!ControlUtils.checkComboBox(ref this.cboDecision, ref lblDecision))
                retval = false;

            return retval;
            /*
            if (this.cboDecision.SelectedIndex < 0)
            {
                lblDecision.ForeColor = Color.Red;
                cboDecision.Focus();
                return false;
            }
            else
            {
                lblDecision.ForeColor = Color.Black;
            }

            if (this.cboDecisionConfidene.SelectedIndex < 0)
            {
                lblDecisionConfidene.ForeColor = Color.Red;
                cboDecisionConfidene.Focus();
                return false;
            }
            else
            {
                lblDecisionConfidene.ForeColor = Color.Black;
            }
             */
            return true;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (validateFields())
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }


    }
}
